<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
//$iso = split( '=', _ISO );
//echo '<?xml version="1.0" encoding=UTF-8"?' .'>';

/* JoomLeague League Management and Prediction Game for Joomla!
 * Copyright (C) 2007  Robert Moss
 *  
 * Homepage: http://www.joomleague.de
 * Support: htt://www.joomleague.de/forum/
 * 
 * This file is part of JoomLeague.
 *  
 * JoomLeague is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Please note that the GPL states that any headers in files and
 * Copyright notices as well as credits in headers, source files
 * and output (screens, prints, etc.) can not be removed.
 * You can extend them with your own credits, though...
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/copyleft/gpl.html.
*/ 


//list($datum, $uhrzeit)=split(" ", $match->match_date);
/*hack referee is another team*/
if ($project->teams_as_referees)
{
  $query = "SELECT id, name FROM #__joomleague_teams ORDER BY name";
  $database->setQuery($query);
  $results = $database->loadObjectList();
  $ref[] = mosHTML::makeOption( '0', _JL_ADMIN_SELECT_REFEREE );
  foreach($results as $result){
	 $ref[] = mosHTML::makeOption($result->id, sprintf("%s", $result->name));
  }
}
else
{
  $query = "SELECT id, firstname, lastname FROM #__joomleague_referees ORDER BY lastname";
  $database->setQuery($query);
  $results = $database->loadObjectList();
  $ref[] = mosHTML::makeOption( '0', _JL_ADMIN_SELECT_REFEREE );
  foreach($results as $result){
    $ref[] = mosHTML::makeOption($result->id, sprintf("%s, %s", $result->lastname, $result->firstname));
  }
}


if($project->allow_add_time){
	$xrounds = array();
	$xrounds[] = mosHTML::makeOption(0, _JL_RESULTS_REGULAR);
	$xrounds[] = mosHTML::makeOption(1, _JL_RESULTS_OVERTIME);
	$xrounds[] = mosHTML::makeOption(2, _JL_RESULTS_PENALTY); 
	$mstl = mosHTML::selectList( $xrounds, "match_result_type$match->match_id", 'class="inputbox" size="1"','value', 'text', $match->match_result_type );
	unset($xrounds);
}
/*
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; encoding=UTF-8" />
*/
?>
<script language="JavaScript" src="<?php echo $mosConfig_live_site; ?>/includes/js/JSCookMenu_mini.js" type="text/javascript"></script>
<script language="JavaScript" src="<?php echo $mosConfig_live_site; ?>/administrator/includes/js/ThemeOffice/theme.js" type="text/javascript"></script>
<script language="JavaScript" src="<?php echo $mosConfig_live_site; ?>/includes/js/joomla.javascript.js" type="text/javascript"></script>
<?php /*
</head>
<body>
*/
?>
<?php
$mainframe->set( 'loadEditor', true );
include_once( $mosConfig_absolute_path . '/editor/editor.php' );
initEditor();
?>
<table class="adminlist2">
<?php
/*
	<tr>
		<th nowrap="nowrap" align="center"><?php echo "NR";?></th>
		<th width="15%" nowrap="nowrap" align="center"><?php echo _JL_ADMIN_EDIT_MATRIX_ROUNDS_DATE;?></th>
		<th width="10%" nowrap="nowrap" align="center"><?php echo _JL_ADMIN_EDIT_MATRIX_ROUNDS_TIME;?></th>
    <th width="30%" nowrap="nowrap" align="right"><?php echo _JL_ADMIN_EDIT_MATRIX_ROUNDS_HOME;?></th>
    <th width="5">&nbsp;</th>
    <th width="30%" nowrap="nowrap" align="left"><?php echo _JL_ADMIN_EDIT_MATRIX_ROUNDS_AWAY;?></th>
    <th width="20%" nowrap="nowrap" align="center"><?php echo _JL_ADMIN_EDIT_MATRIX_ROUNDS_RESULT;?></th>
  </tr>

	<tr>
		<td>
			<input type="text" class="inputbox" style="font-size:9px;" name="match_number<?php echo $match->match_id;?>" value="<?php echo $match->match_number;?>" size="3" /></td>
		<td nowrap="nowrap">
			<input type="text" style="font-size:9px;" name="match_date<?=$match->match_id;?>" id="match_date<?=$match->match_id;?>" value="<?php echo $datum;?>" size="12" class="inputbox" />
			<input type="reset" style="font-size:9px;" class="inputbox" value="..." onclick="return showCalendar('match_date<?=$match->match_id;?>', 'y-mm-dd');" />
		</td>
		<td align="center" nowrap="nowrap">
			<input type="text" style="font-size:9px;" name="match_time<?=$match->match_id;?>" value="<?php echo $uhrzeit;?>" size="9" class="inputbox" />
		</td>
    <td nowrap="nowrap" align="right">
    	<?php
    	echo mosHTML::selectList( $teamsoptions, "matchpart1$match->match_id", 'class="inputbox" style="font-size:9px;" size="1"','value', 'text', $match->matchpart1 );
    	//echo $match->matchpart1;
    	?>
    </td>
    <td width="5">-</td>
    <td nowrap="nowrap" align="left">
    	<?php
    	echo mosHTML::selectList( $teamsoptions, "matchpart2$match->match_id", 'class="inputbox" style="font-size:9px;" size="1"','value', 'text', $match->matchpart2 );
    	//echo $match->matchpart2;
    	?>
    </td>
    <td nowrap="nowrap" align="center">
    	<input type="text" style="font-size:9px;" name="matchpart1_result<?php echo $match->match_id;?>" value="<?php echo $match->matchpart1_result;?>" size="3" tabindex="1" class="inputbox" />
    	:
    	<input type="text" style="font-size:9px;" name="matchpart2_result<?php echo $match->match_id;?>" value="<?php echo $match->matchpart2_result;?>" size="3" tabindex="1" class="inputbox" />
    </td>
  </tr>
*/
?>
  <tr>
  	<td colspan="7" align="right">
  	<?php
if ($project->use_legs==1) { ?>
    Legs:
    <input type="text" style="font-size:9px;" name="matchpart1_legs<?php echo $match->match_id;?>" value="<?php echo $match->matchpart1_legs;?>" size="3" tabindex="1" class="inputbox" />
    	:
    	<input type="text" style="font-size:9px;" name="matchpart2_legs<?php echo $match->match_id;?>" value="<?php echo $match->matchpart2_legs;?>" size="3" tabindex="1" class="inputbox" /> | 
<?php } ?>
<?php 
  	echo _JL_ADMIN_EDIT_FORM_PLAYGROUNDS_TITLE.": ".$playgroundslist."&nbsp;";
  	echo _JL_ADMIN_EDIT_MATRIX_ROUNDS_PART_RESULT;?>: <?php
				$partresults1=explode(";", $match->matchpart1_result_split);
        $partresults2=explode(";", $match->matchpart2_result_split);
        for ($x=0;$x<($project->game_parts-1);$x++)
        { echo ($x+1).".: ";
        	?>
          <input type="text" style="font-size:9px;" name="matchpart1_result_split<?php echo $match->match_id;?>[]" value="<?php echo $partresults1[$x];?>" size="3" tabindex="1" class="inputbox" />
          :
          <input type="text" style="font-size:9px;" name="matchpart2_result_split<?php echo $match->match_id;?>[]" value="<?php echo $partresults2[$x];?>" size="3" tabindex="1" class="inputbox" />
        &nbsp;
      <? } ?>
  		      <?php	
			if($project->allow_add_time){ echo _JL_ADMIN_EDIT_MATRIX_ROUNDS_TYPE.'&nbsp; '.$mstl.'&nbsp; '; }
			echo _JL_ADMIN_PUBLISHED;?>
			<select style="font-size:9px;" name="published<?php echo $match->match_id;?>">
			<option value="0"<?php echo ($match->published==0)?' selected="selected"':'';?>><?php echo _CMN_NO ?></option>
			<option value="1"<?php echo ($match->published==1)?' selected="selected"':'';?>><?php echo _CMN_YES ?></option>
			</select>
		</td>
	</tr>
</table>
<table class="adminlist2">
	<tr>
		<td width="60%">
			<table>
			<tr><td><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_RESULT_DECISION; ?></td>
	    <td><select style="font-size:9px;" name="alt_decision<?php echo $match->match_id;?>" id="alt_decision<?php echo $match->match_id;?>" onchange="javascript:FormSwitch(<?php echo $match->match_id;?>, this.options[this.selectedIndex].value)" >
			<option value="0"<?php if ($match->alt_decision==0) echo ' selected="selected"' ?>><?php echo _CMN_NO ?></option>
			<option value="1"<?php if ($match->alt_decision==1) echo ' selected="selected"' ?>><?php echo _CMN_YES ?></option>
			</select>
    	</td>
	</tr>
			<tr>
				<td><?php echo _JL_ADMIN_EDIT_FORM_MATCHEVENTS_NOTICE;?></td><td><input style="font-size:9px;" type="text" name="match_result_detail<?php echo $match->match_id;?>" value="<?php echo utf8_encode($match->match_result_detail);?>" size="30" class="inputbox" />
				</td>
			</tr>
			<tr>
				<td><?php echo _JL_REPORT_CROWD;?></td>
				<td><input type="text" style="font-size:9px;" name="crowd<?php echo $match->match_id;?>" value="<?php echo $match->crowd;?>" size="6" class="inputbox" /></td>
			</tr>
			<tr>
				<td><?php echo _JL_REPORT_REFEREE;?></td>
				<td>
<?php 
echo mosHTML::selectList( $ref, 'referee_id'.$match->match_id, 'class="inputbox" style="font-size:9px;" size="1"','value', 'text', $match->referee_id );
?>			</td>
			</tr>
			<tr>
				<td><?php echo _JL_REPORT_DETAIL;?>:</td>
				<td><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_SHOW_MATCHREPORT;?>
				<select style="font-size:9px;" name="show_report<?php echo $match->match_id;?>">
			<option value="0"<?php echo ($match->show_report==0)?' selected="selected"':'';?>><?php echo _CMN_NO ?></option>
			<option value="1"<?php echo ($match->show_report==1)?' selected="selected"':'';?>><?php echo _CMN_YES ?></option>
			</select>
</td>
			</tr>
		</table>
		</td>
		<td>
<table>
    <tr>
		<td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_HOME_NEW;?></td>
		<td><input type="text" style="font-size:9px;" class="inputbox" id="matchpart1_result_decision<?php echo $match->match_id;?>" name="matchpart1_result_decision<?php echo $match->match_id;?>" size="3" value="<?php if ($match->alt_decision == 1) if (isset($match->matchpart1_result_decision)) echo $match->matchpart1_result_decision; else echo 'X'; ?>" <?php if ($match->alt_decision == 0) echo 'DISABLED ' ?>/></td>
	</tr>
    <tr>
      <td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_AWAY_NEW;?></td>
      <td><input type="text" style="font-size:9px;" class="inputbox" id="matchpart2_result_decision<?php echo $match->match_id;?>" name="matchpart2_result_decision<?php echo $match->match_id;?>" size="3" value="<?php if ($match->alt_decision == 1) if (isset($match->matchpart2_result_decision)) echo $match->matchpart2_result_decision; else echo 'X'; ?>" <?php if ($match->alt_decision == 0) echo 'DISABLED ' ?>/></td>
    </tr>
    <tr>
      <td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_NOTICE_NEW;?></td><?php if (is_null($match->matchpart1_result) or ($match->alt_decision == 0)) $disinfo='DISABLED '; ?>
      <td><input type="text" style="font-size:9px;" class="inputbox" id="decision_info<?php echo $match->match_id;?>" name="decision_info<?php echo $match->match_id;?>" size="30" value="<?php if ($match->alt_decision == 1) echo $match->decision_info; ?>" <?php if ($match->alt_decision == 0) echo 'DISABLED ' ?>/></td>
    </tr>
    <tr>
      <td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_COUNT_MATCH;?></td>
      <td><?php echo mosHTML::yesnoRadioList('count_result', '', $match->count_result );?></td>
    </tr>
</table>
</td>
</tr>
			<tr>
				<td colspan="2">
	<?php 

	editorArea( 'editor1',  utf8_encode($match->summary) , 'summary'.$match->match_id, '98%', '200', '50', '5' ) ;

	?>
	<br /><a id="control" href="" onclick="showeditor('summary<?php echo $match->match_id;?>', 'control');return false;">show editor</a></span></td>
	</tr>
	</table>
<?php
/*
</body></html>
*/
?>
